package de.iritgo.skillfull.entity.command;

import java.awt.Point;

import de.iritgo.skillfull.component.visitor.AnimationVisitor;
import de.iritgo.skillfull.component.visitor.PositionVisitor;
import de.iritgo.skillfull.entity.Command;
import de.iritgo.skillfull.entity.Entity;

public class AnimationCommand implements Command 
{
	private Entity entity;
	private boolean done;
	private boolean loop;
	private AnimationVisitor animationVisitor;
	private PositionVisitor positionVisitor;
	
	public AnimationCommand (Entity entity, Point pos, boolean loop)
	{
		this.entity = entity;
		this.loop = loop;
		done = false;
		animationVisitor = new AnimationVisitor (false, false);
		positionVisitor = new PositionVisitor (pos.x, pos.y, false);
	}

	public String getName ()
	{
		return "Animation"; 
	}

	@Override
	public boolean canPerform () 
	{
		return true;
	}

	@Override
	public void perform (int delta) 
	{
		entity.accept (positionVisitor);
		entity.accept (animationVisitor);
	}
	
	@Override
	public void stop() 
	{
		done = true;
	}

	public Command getUndoCommand () 
	{
		return null;
	}

	@Override
	public boolean isDone () 
	{
		return animationVisitor.isDone ();
	}
}
